package com.ruoyi.costumeShop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.costumeShop.domain.CostumeSaleOrderDetail;
import com.ruoyi.costumeShop.service.ICostumeSaleOrderDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * saleOrderDetailController
 * 
 * @author ruoyi
 * @date 2022-04-05
 */
@RestController
@RequestMapping("/costumeShop/saleOrderDetail")
public class CostumeSaleOrderDetailController extends BaseController
{
    @Autowired
    private ICostumeSaleOrderDetailService costumeSaleOrderDetailService;

    /**
     * 查询saleOrderDetail列表
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:saleOrderDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(CostumeSaleOrderDetail costumeSaleOrderDetail)
    {
        startPage();
        List<CostumeSaleOrderDetail> list = costumeSaleOrderDetailService.selectCostumeSaleOrderDetailList(costumeSaleOrderDetail);
        return getDataTable(list);
    }

    /**
     * 导出saleOrderDetail列表
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:saleOrderDetail:export')")
    @Log(title = "saleOrderDetail", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CostumeSaleOrderDetail costumeSaleOrderDetail)
    {
        List<CostumeSaleOrderDetail> list = costumeSaleOrderDetailService.selectCostumeSaleOrderDetailList(costumeSaleOrderDetail);
        ExcelUtil<CostumeSaleOrderDetail> util = new ExcelUtil<CostumeSaleOrderDetail>(CostumeSaleOrderDetail.class);
        util.exportExcel(response, list, "saleOrderDetail数据");
    }

    /**
     * 获取saleOrderDetail详细信息
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:saleOrderDetail:query')")
    @GetMapping(value = "/{saleOrderDetailId}")
    public AjaxResult getInfo(@PathVariable("saleOrderDetailId") Long saleOrderDetailId)
    {
        return AjaxResult.success(costumeSaleOrderDetailService.selectCostumeSaleOrderDetailBySaleOrderDetailId(saleOrderDetailId));
    }

    /**
     * 新增saleOrderDetail
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:saleOrderDetail:add')")
    @Log(title = "saleOrderDetail", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CostumeSaleOrderDetail costumeSaleOrderDetail)
    {
        return toAjax(costumeSaleOrderDetailService.insertCostumeSaleOrderDetail(costumeSaleOrderDetail));
    }

    /**
     * 修改saleOrderDetail
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:saleOrderDetail:edit')")
    @Log(title = "saleOrderDetail", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CostumeSaleOrderDetail costumeSaleOrderDetail)
    {
        return toAjax(costumeSaleOrderDetailService.updateCostumeSaleOrderDetail(costumeSaleOrderDetail));
    }

    /**
     * 删除saleOrderDetail
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:saleOrderDetail:remove')")
    @Log(title = "saleOrderDetail", businessType = BusinessType.DELETE)
	@DeleteMapping("/{saleOrderDetailIds}")
    public AjaxResult remove(@PathVariable Long[] saleOrderDetailIds)
    {
        return toAjax(costumeSaleOrderDetailService.deleteCostumeSaleOrderDetailBySaleOrderDetailIds(saleOrderDetailIds));
    }
}
